<template>
    <a-input :size="option.size" :disabled="readonly" :placeholder="option.placeholder" :allowClear="option.allowClear"
        v-model:value="InputValue">
        <template #suffix>
            {{ option.Unit }}
        </template>
    </a-input>
</template>
<script setup>
import { ref, watch, watchEffect } from 'vue';

const emit = defineEmits(['UpdateEvent', 'SetError']);

const props = defineProps({
    option: Object,
    Value: {},
});

const readonly = ref(false);
const InputValue = ref();

watchEffect(() => {
    readonly.value = !!props.option.readonly
})

watch(() => props.Value[props.option.key], val => {
    InputValue.value = val
}, { immediate: true });

watch(InputValue, (val) => {
    emit('UpdateEvent', props.option.key, val);
}, { immediate: true })

</script>
<style lang="less" scoped></style>